<?php

namespace App\Http\Controllers\ChatGroup\Web;

use App\Http\Controllers\BaseController;
use App\Models\ChatGroup\ChatGroupFAQModel;
use App\Service\ChatGroup\ChatGroupService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;

class ChatGroupController extends BaseController
{

    /**
     * 获得历史数据
     * @param Request $request
     * @return JsonResponse
     * @throws ValidationException
     */
    public function historyStatistics(Request $request): JsonResponse
    {
        $this->validate($request, [
            'shopId' => 'required|int'
        ]);

        $shopId = $request->get('shopId');

        return $this->success(ChatGroupService::historyStatistics($shopId));
    }


    /**
     * 发送工单链接配置
     * @return JsonResponse
     */
    public function workOrderSendUrl(): JsonResponse
    {
        return $this->success(ChatGroupService::workOrderSendUrl());
    }

    /**
     * 常见问题
     * @return JsonResponse
     */
    public function faq(): JsonResponse
    {
        return $this->success(ChatGroupFAQModel::faq());
    }
}
